var t = getApp();

Page({
    data: {
        step: 1,
        radio: "",
        list: [],
        order_pay_id: "",
        smsMobile: "",
        token: "",
        btnText: "获取验证码",
        timer: null,
        btnTag: !1
    },
    onLoad: function(t) {
        wx.setNavigationBarTitle({
            title: "快捷支付-银典"
        }), t.order_pay_id && this.setData({
            order_pay_id: t.order_pay_id
        }), t.sn && this.setData({
            sn: t.sn
        }), t.money && this.setData({
            money: t.money
        }), this.getData();
    },
    radiochange: function(t) {
        var a = t.detail;
        this.setData({
            radio: a
        });
    },
    next: function() {
        t._isTextEmpty(this.data.radio) ? wx.showModal({
            content: "请选择银行卡",
            showCancel: !1
        }) : this.setData({
            step: 2
        });
    },
    confirmBtn: function() {
        t._isTextEmpty(this.data.smsMobile) ? wx.showModal({
            content: "请输入验证码",
            showCancel: !1
        }) : this.unionPay();
    },
    checkCodeMethod: function() {
        var a = this, n = {
            order_pay_id: this.data.order_pay_id,
            pay_union_card_id: this.data.radio
        };
        t._getNetWork({
            url: t.getNetAddresss("order.merge-pay.silver-point-union-pay"),
            data: n,
            success: function(n) {
                n.data.result ? (a.setData({
                    token: n.data.data.pay_msg.token
                }), a.sendCodeAnimation()) : t.tips(n.data.msg);
            }
        });
    },
    unionPay: function() {
        var a = this, n = {
            ids: this.data.order_pay_id
        };
        this.data.sn && (n.sn = this.data.sn), t._getNetWork({
            url: t.getNetAddresss("plugin.silver-point-pay.frontend.union-card.pay"),
            data: {
                code: this.data.smsMobile,
                token: this.data.token,
                order_pay_id: this.data.order_pay_id
            },
            success: function(n) {
                n.data.result ? "101" == n.data.data.status ? a.orderCheck() : wx.navigateTo({
                    url: "/packageI/pay_back/pay_back?ids=" + a.data.order_pay_id + "&sn=" + a.data.sn
                }) : t.tips(n.data.msg);
            }
        });
    },
    orderCheck: function() {
        var a = this, n = {
            ids: this.data.order_pay_id
        };
        this.data.sn && (n.sn = this.data.sn), t._getNetWork({
            url: t.getNetAddresss("plugin.silver-point-pay.frontend.union-card.queryOrder"),
            data: {
                pay_sn: this.data.sn
            },
            success: function(n) {
                n.data.result ? wx.navigateTo({
                    url: "/packageI/pay_back/pay_back?ids=" + a.data.order_pay_id + "&sn=" + a.data.sn
                }) : (t.tips(n.data.msg), wx.navigateBack({
                    delta: 1
                }));
            }
        });
    },
    sendCodeAnimation: function() {
        var t = this;
        this.data.timer || (this.data.count = 60, wx.showToast({
            title: "验证码已发送",
            icon: "success",
            duration: 1e3
        }), this.data.timer = setInterval(function() {
            t.data.count > 0 && t.data.count <= 60 ? (t.data.count--, t.setData({
                btnTag: !0,
                btnText: t.data.count + "s"
            })) : (t.setData({
                btnTag: !1,
                btnText: "获取验证码"
            }), clearInterval(t.data.timer), t.data.timer = null);
        }, 1e3));
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    getData: function() {
        var a = this;
        t._getNetWork({
            url: t.getNetAddresss("plugin.silver-point-pay.frontend.union-card.index"),
            success: function(n) {
                n.data.result ? a.setData({
                    list: n.data.data
                }) : t.tips(n.data.msg);
            }
        });
    }
});